<extend name="Console:index"/>
<block name="main">

    <!--路径导航-->
    <div>
        <ol class="breadcrumb">
            <li>首页管理</li>
            <li>电影管理</li>
            <li class="active">编辑电影</li>
            <li class="active"> <a href="{$Think.server.http_referer}" class="btn btn-default btn-xs" >返回上一页</a></li>
        </ol>

    </div>
    <div style="margin-left: 10px">
       <div>

           <form class="form-horizontal" action="{:U('Movie/edit')}" enctype="multipart/form-data"  method="post">

               <input type="hidden" name="id" value="{$data.id}">
               
               <div class="form-group">
                   <label for="inputtext1" class="col-sm-2 control-label" style="color:red">名称: </label>
                   <div class="col-sm-4">
                       <input type="text" class="form-control" id="inputtext1" name="name" value="{$data.name}" required="">
                   </div>
               </div>
               <div class="form-group">
                   <label for="inputtext1" class="  col-sm-2 control-label" style="color:red">标题: </label>
                   <div class="col-sm-4">
                       <input type="text" class="form-control" id="inputtext2" name="title" value="{$data.title}" required="">
                   </div>
                   <span>最多1000个字</span>
               </div>


               <div class="form-group">
                   <label for="inputtext10012000" class="col-sm-2 control-label" style="color:red">选择栏目:</label>
                   <div class="col-sm-4">
                       <select   class="form-control" id="inputtext10012000" name="columns" required>
                           <option value="">请选择栏目</option>


                           <foreach name="co" item="vo">

                               <option value="{$key}"   <eq name="data.columns" value="$key"> selected</eq> >{$key}-{$vo}</option>
                           </foreach>

                       </select>
                   </div>
               </div>

               <div class="form-group">
                   <label for="inputtext100130" class="col-sm-2 control-label" style="color:red">选择国家:</label>
                   <div class="col-sm-4">
                       <select   class="form-control" id="inputtext100130" name="country_id" required>
                           <option value="">请选择栏目</option>

                           <volist name="country" id="co">
                               <option value="{$co.country_id}"   <eq name="data.country_id" value="$co.country_id"> selected</eq> >{$co.name}</option>
                           </volist>

                       </select>
                   </div>
               </div>



               <div class="form-group">
                   <label for="inputtext1001300" class="col-sm-2 control-label" style="color:red">选择电影类型:</label>
                   <div class="col-sm-4">
                       <select   class="form-control" id="inputtext1001300" name="movie_type" required>
                           <option value="">请选择类型</option>

                           <volist name="movie_type" id="mt">
                               <option value="{$mt.country_id}"  <eq name="data.movie_type" value="$mt.country_id"> selected</eq>  >{$mt.name}</option>
                           </volist>

                       </select>
                   </div>
               </div>

               <div class="form-group">
                   <label for="inputtext22" class="  col-sm-2 control-label" >原分类封面: </label>
                   <div class="col-sm-4">
                       <img src="{$data.image}" alt="没有关联图片" width="80px">
                   </div>
               </div>

               <div class="form-group">
                   <label for="inputtext22" class="  col-sm-2 control-label" >新分类封面: </label>
                   <div class="col-sm-4">
                       <input type="file" id="inputtext22" name="image" >
                   </div>
               </div>


               <div class="form-group">
                   <label for="inputtext100" class="  col-sm-2 control-label" style="color:red">上映年限:</label>
                   <div class="col-sm-4">
                       <input onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" type="text" class="form-control" id="inputtext100" name="show_time" required="" value="{$data.show_time}" >
                   </div>
               </div>


               <div class="form-group">
                   <label  class="  col-sm-2 control-label" style="color:red">上映时间：</label>
                   <div class="col-sm-4">
                       <div class="input-group">
                           <input class="form-control"  type='text' name="play_time" id ="play_time" required  value="{$data.play_time}">
                       </div>
                   </div>
               </div>

               <div class="form-group">
                   <label  class="  col-sm-2 control-label" style="color:red">下架时间：</label>
                   <div class="col-sm-4">
                       <div class="input-group">
                           <input class="form-control" type='text' name="end_time" id ="end_time" required  value="{$data.end_time}">
                       </div>
                   </div>
               </div>

               <div class="form-group ">
                   <label for="inputtext2" class="  col-sm-2 control-label" style="color:red">关注数</label>
                   <div class="col-sm-4">
                       <input type="text" class="form-control" id="inputtext4" name="collection" required="" value="{$data.collection}">
                   </div>
               </div>


               <div class="form-group">
                   <label for="inputtext10012" class="  col-sm-2 control-label" style="color:red">排序:</label>
                   <div class="col-sm-4">
                       <input type="text" class="form-control" id="inputtext10014"   name="sort" value="{$data.sort}"  >
                   </div>
               </div>


               <div class="form-group">
                   <label  class="  col-sm-2 control-label" style="color:red">搜索关键字:</label>
                   <div class="col-sm-4">
                       <input type="text" class="form-control"  name="search_keywords" value="{$data.search_keywords}" required=""  id="search_keywords" placeholder="格式如下：key1,key2,key3">
                       <span style="color: red">最多80个中文与符号。关键字之间使用(英文逗号)分隔</span>
                   </div>
               </div>


               <input type="reset" value="重置" class="btn btn-warning col-sm-offset-2 col-sm-1"/>
               <input type="submit" value="保存" class="btn btn-warning  col-sm-offset-1 col-sm-1"/>

           </form>

       </div>
    </div>


    <script>
        $(function(){

            //时间选择插件设置
            var play_time = {
                elem: '#play_time',
                format: 'YYYY-MM-DD',

                max: '2099-06-16', //最大日期
                istime: true,
                istoday: false,
                choose: function(datas){
                    end_time.min = datas; //开始日选好后，重置结束日的最小日期
                    end_time.start = datas; //将结束日的初始值设定为开始日
                }
            };

            var end_time = {
                elem: '#end_time',
                format: 'YYYY-MM-DD',

                max: '2099-06-16',
                istime: true,
                istoday: false,
                choose: function(datas){
                    play_time.max = datas; //结束日选好后，重置开始日的最大日期
                }
            };

            laydate(play_time);
            laydate(end_time);

            $("#search_keywords").blur(function(){
                var num = $("#search_keywords").val();

                if ("" != num){
                    if (contains(num, "，", true)){
                        alert("含有中文逗号，已经转换为英文逗号。");
                        num=num.replace(/，/ig,',');
                        $('#search_keywords').val(num);

                    }
                }
            });
        });


        /**
         * 判断 str 字符串中是否含有字符串 subStr
         * @param {} str 原字符串
         * @param {} subStr 要查找的字符串
         * @param {} isIgnoreCase 是否忽略大小写
         * @return {Boolean}
         */
        function contains(str, subStr, isIgnoreCase) {

            if (isIgnoreCase) {
                // 忽略大小写
                str = str.toLowerCase();
                subStr = subStr.toLowerCase();
            }

            var startChar = subStr.substring(0,1);
            var strLen = subStr.length;

            for (var j=0; j<str.length-strLen+1; j++) {
                if (str.charAt(j) == startChar) {
                    /* 如果匹配起始字符,开始查找 */
                    if (str.substring(j, j+strLen) == subStr) {
                        /*如果从j开始的字符与 str 匹配 */
                        return true;
                    }
                }
            }
            return false;
        }
    </script>
</block>